home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / actlib13.zip / STRINGS.ZIP / COMP.C < prev    next >
Text File  |  1993-04-16  |  853b  |  32 lines

  1. /*  Copyright (C) 1993   Marc Stern  (internet: stern@mble.philips.be)  */
  2.  
  3. #include "strings.h"
  4.  
  5.  
  6. /***
  7.  *  Function    :  strcomp
  8.  *
  9.  *  Description :  Compare two strings case-insensitive
  10.  *           All special characters are translated (éèà...)
  11.  *
  12.  *  Parameters  :  in   char  *str1
  13.  *                 in   char  *str2
  14.  *                 
  15.  *  Return      :  -1 if str1 <  str2
  16.  *            1 if str1 >  str2
  17.  *            0 if str1 == str2
  18.  *
  19.  *  OS/Compiler :  All
  20.  ***/
  21.  
  22. int strcomp( const char *str1, const char *str2 )
  23.  
  24. {
  25.   for (; *str1 && *str2; str1++, str2++ )
  26.       if ( chcase(*str1, UPPER) != chcase(*str2, UPPER) ) break;
  27.                                                       
  28.   if ( chcase(*str1, UPPER) <  chcase(*str2, UPPER) ) return -1;
  29.   if ( chcase(*str1, UPPER) >  chcase(*str2, UPPER) ) return  1;
  30.   return 0;
  31. }
  32.